package com.android.broad;

import com.android.broad.R;
import com.android.broad.domain.RootMe;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.ToggleButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class MainBroadCast extends Activity {
	
	
  /** Called when the activity is first created. */
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    final ToggleButton b = (ToggleButton) findViewById(R.id.ToogleServiceButton);
    b.setChecked(Service.isRunning());
    
    
    b.setOnCheckedChangeListener(new OnCheckedChangeListener() {

		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			// TODO Auto-generated method stub      public void onCheckedChanged(final CompoundButton buttonView,
	        if (isChecked){
	               Service.start(getApplicationContext(), true);

	              Intent intent = new Intent();
	              intent.setComponent(new ComponentName(getApplicationContext(), RootMe.class));
	              startActivity(intent);
	         }
	         else
	                Service.stop(getApplicationContext(), true);
	    }

    
    });
  }
}